#include<iostream>
#include<vector>
#include<iomanip>

using namespace std;

class Solution {
public:
    double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
        vector<int> mergeVec;
        vector<int>::size_type size1=0, size2=0;
        double result;
        size1 = nums1.size();
        size2 = nums2.size();

        int limit = (size1 + size2)/2 + 1;

        int i, index1, index2, min=0;
        index1 = (size1) ? 0 : -1;
        index2 = (size2) ? 0 : -1;
        int num1 = index1 ? 0 : nums1.at(index1);
        int num2 = index2 ? 0 : nums2.at(index2);
        for(i=0; i<limit && index1!=-1 && index2!=-1; i++) {
            min = ( num1<num2 ) ? num1 : num2;
            mergeVec.push_back(min);
            //cout << "mergeVec.at(" << i << ") " << mergeVec.at(i) << endl;

            index1 = (num1<num2) ? ((index1+1<size1)?index1+1:-1) : index1;
            index2 = (num1<num2) ? index2 : (index2+1<size2?index2+1:-1);
            //cout << "index1 " << index1 << endl;
            //cout << "index2 " << index2 << endl;

            // index1==-1 num1可以为任何值， 后面不会用到，这里赋为0, num2同样处理
            if (num1<num2)
                if(index1==-1)
                    num1 = 0;
                else
                    num1 = nums1.at(index1);
            else if(index2==-1)
                num2 = 0;
            else
                num2 = nums2.at(index2);
        }
        if(index1==-1)
            for(; i<limit; i++) {
                mergeVec.push_back(num2);
                index2 = index2+1<size2 ? index2+1 : -1;
                if(index2==-1)
                    num2 = 0;
                else
                    num2 = nums2.at(index2);
            }
        else if(index2==-1)
            for(; i<limit; i++) {
                mergeVec.push_back(num1);
                index1 = index1+1<size1 ? index1+1 : -1;
                if(index1==-1)
                    num1 = 0;
                else
                    num1 = nums1.at(index1);
            }

        result = (size1 + size2)%2 ? mergeVec.at(limit-1) : (double)( mergeVec.at(limit-2)+mergeVec.at(limit-1) )/2;

        return result;    
    }

};

void strToVec(string str, vector<int> &vec) {
    string::size_type num = str.size();
    if (num == 2) return ;

    for(int i=1; i<num; i+=2) {
        int element = atoi( &str.at(i) );
        vec.push_back(element);
    }

    return ;
}

int main() {
    Solution solution;

    char charIn[2048] = {0};
    cin.getline(charIn, 2048, '\n');
    string strIn(charIn);
    string::size_type l1StartPos = strIn.find_first_of('[');
    string::size_type l1EndPos = strIn.find_first_of(']');
    string::size_type l2StartPos = strIn.find_last_of('[');
    string::size_type l2EndPos = strIn.find_last_of(']');
    string l1Str = strIn.substr(l1StartPos, l1EndPos-l1StartPos+1);
    string l2Str = strIn.substr(l2StartPos, l2EndPos-l2StartPos+1);

    vector<int> l1Vec;
    vector<int> l2Vec;
    strToVec(l1Str, l1Vec);
    strToVec(l2Str, l2Vec);

    cout << fixed << setprecision(5) << solution.findMedianSortedArrays(l1Vec, l2Vec) << endl;

    return 0;
}
